home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 160 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.std.c
  4. Subject: Re: atexit() and return from main()
  5. Date: 22 Jan 1996 15:43:09 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan22084309@qcd.lanl.gov>
  8. References: <4dhfja$j50@fg70.rz.uni-karlsruhe.de> <4diicg$i9e@lyra.csx.cam.ac.uk>
  9.     <TANMOY.96Jan18084025@qcd.lanl.gov>
  10.     <DLKrx7.6p6@ukpsshp1.serigate.philips.nl>
  11. NNTP-Posting-Host: qcd.lanl.gov
  12. Mime-Version: 1.0
  13. Content-Type: text
  14. In-reply-to: baynes@ukpsshp1.serigate.philips.nl's message of Mon, 22 Jan 1996 09:05:31 GMT
  15.  
  16. --text follows this line--
  17. In article <DLKrx7.6p6@ukpsshp1.serigate.philips.nl>
  18. baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) writes: 
  19. <snip>
  20.    <snip>
  21.    :    main() calls setjmp() and then calls exit().  An atexit() function
  22.    :    calls longjmp() and returns to main().  This repeats (or does it?)
  23.  
  24.    : Neither of these is permitted in any sense that I understand!
  25.    : 7.10.4.3: If more than one call to the exit function is executed by
  26.    : a program, the behaviour is undefined. No `permission by omission'
  27.    : that I can see.
  28.  
  29.    In this example what happens if no second call to exit is been made (after
  30.    longjumping back to main the program does not attempt to call exit again -
  31.    instead it keeps executing indefinately)?
  32.  
  33. I don't understand the question: are you asking what happens if a
  34. program keeps executing indefinitely? Well, it just keeps executing
  35. indefinitely. After that infinite period, the rest of the exit
  36. processing happens and a return status is indicated to the rts.
  37.  
  38.    Does a return from main count as a call to exit for the purposes of the
  39.    one call restriction in 7.10.4.3? I assume it does because it is regarded
  40.    as equivalent.
  41.  
  42. I think so.
  43.  
  44.    What happens if an atexit function calls atexit ? If you interpret the
  45.    standard strictly I think the program has to enter a timewarp back to the
  46.    call to exit and start with the just registered atexit function!
  47.  
  48. I do not agree. An atexit registers a function to be called at normal
  49. program termination: and the only reference to normal program
  50. termination I find is the call to exit. So, if there is no further
  51. call to exit there is not _further_ normal program termination: and if
  52. there is a call to exit, the behaviour is undefined :-)
  53.  
  54. My sense of aesthetics rebels at the notion of `further normal program
  55. termination': probably a better wording is possible.
  56.  
  57. Cheers
  58. Tanmoy
  59. --
  60. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  61. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  62. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  63. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  64. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  65. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  66.